//package com.wood.life.service.Impl;
//
//import com.night.common.entity.life.Ticket;
//import com.wood.life.mapper.TicketMapper;
//import com.wood.life.service.TicketService;
//import org.springframework.beans.factory.annotation.Autowired;
//import org.springframework.data.redis.core.ListOperations;
//import org.springframework.data.redis.core.RedisTemplate;
//import org.springframework.data.redis.core.StringRedisTemplate;
//import org.springframework.data.redis.core.ValueOperations;
//import org.springframework.stereotype.Service;
//import org.springframework.transaction.annotation.Transactional;
//
//import java.util.Locale;
//
///**
// * author: dz
// * 2022-10-20-19:58
// */
////@Service
//@Transactional
//public class TicketServiceImpl implements TicketService {
//    @Autowired
//    TicketMapper ticketMapper;
//    @Autowired
//    RedisTemplate redisTemplate;
//
//    ValueOperations valueOperations = redisTemplate.opsForValue();
//
//    @Override
//    public void insert(Ticket ticket) {
//        System.out.println("----------" + ticket);
//        ticketMapper.insert(ticket);
//
//        for (int i = 1; i <= ticket.getStock(); i++) {
//            valueOperations.set(ticket.getTitle(), "优惠卷数量" + i);
//        }
//
//        System.out.println("ok");
//    }
//
//    @Override
//    public Ticket getById(Integer id) {
//        return ticketMapper.getById(id);
//    }
//
//    @Override
//    public void deleteById(Integer id) {
//        //根据id查键，从redis删除
////        Ticket ticket = ticketMapper.getById(id);
////        ticketMapper.deleteById(id);
////        stringRedisTemplate.delete(ticket.getTitle());
//    }
//
//    @Override
//    public boolean getTicket(String title) {
////        String ticket = stringStringListOperations.rightPop(title);
////        if (ticket==null){
////            return false;
////        }
//        return true;
//    }
//}
